#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <errno.h>



#define INFO_RX    "./info_rx"
#define INFO_TX    "/info_tx"




int g_socket = -1;



int main()
{
    int ret;
    int flags;
    int buf_size = 2*1024;
    
    struct sockaddr_un cliaddr;
    
    g_socket = socket(PF_LOCAL, SOCK_DGRAM, 0);

    if (0 > g_socket)
    {
        printf("%s %d FAILED\n", __func__, __LINE__);
        return -1;
    }


    unlink(INFO_RX);
    
    bzero(&cliaddr, sizeof(cliaddr));
    cliaddr.sun_family = AF_LOCAL;
    strcpy(cliaddr.sun_path, INFO_RX);


    
    ret = setsockopt(g_socket, SOL_SOCKET, SO_SNDBUF, &buf_size, sizeof(buf_size));
    if (0 > ret)
    {
        printf("%s %d FAILED\n", __func__, __LINE__);
        return -1;
    }


    flags = fcntl(g_socket, F_GETFL, 0);
    flags |= O_NONBLOCK;
    fcntl(g_socket, F_SETFL, flags);
    

    ret = bind(g_socket, (struct sockaddr*)&cliaddr, sizeof(cliaddr));
    if (0 > ret)
    {
        printf("%s %d FAILED\n", __func__, __LINE__);
        return -1;
    }


    close(g_socket);

}




int msg_socket_recv()
{
    
}
